#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    /* Point() */
    /* : _ix(0) */
    /* , _iy(0) */
    /* { */
    /*     cout << "Point()" << endl; */
    /* } */

    Point(int x ,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }
    

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")";
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
private:
    int _ix;
    int _iy;
};

class Line
{
public:
    Line(int x1,int y1,int x2,int y2)
    //在初始化列表中对对象成员进行初始化
    //实际就是调用Point的构造函数
    //如果初始化列表中没有显式调用对象成员的构造函数
    //编译器会自动调用对象成员的无参构造
    : _pt1(x1,y1) //相当于Point _pt1(x1,y1)
    , _pt2(x2,y2) //这里括号前写的是对象成员的名字
    {
        cout << "Line(int*4)" << endl;
    }
    
    void printLine(){
        _pt1.print();
        cout << "------>";
        _pt2.print();
        cout << endl;
    }

    ~Line(){
        cout << "~Line()" << endl;
    }
private:
    Point _pt1;
    Point _pt2;
};

void test0(){
    Line ll(1,2,3,4);
    ll.printLine();
    cout << sizeof(Line) << endl;
}

int main(void){
    test0();
    return 0;
}
